import java.util.Scanner;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:${USER}
 * Date:${YEAR}-${MONTH}-${DAY}
 * ${TIME}
 */
public class Main {

}


//Definition for singly-linked list.
class ListNode {
     int val;
     ListNode next;
   ListNode() {}
    ListNode(int val) { this.val = val; }
    ListNode(int val, ListNode next) { this.val = val; this.next = next; }
}


class Solution {
    public ListNode addTwoNumbers(ListNode l1, ListNode l2) {//链表两数相加
        ListNode newNode=new ListNode(0);
        ListNode start=newNode;
        int t=0;
        while(l1!=null||l2!=null||t!=0){
            if(l1!=null){
                t+=l1.val;
                l1=l1.next;
            }
            if(l2!=null){
                t+=l2.val;
                l2=l2.next;
            }
            newNode.next=new ListNode(t%10);
            newNode=newNode.next;
            t=t/10;
        }
        return start.next;
    }
}